package me.boot.db.mybatis.interceptor.tablename.impl;

import cn.hutool.core.util.StrUtil;
import me.boot.db.mybatis.interceptor.tablename.BaseTableNameHandler;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 按天分表解析
 */
public class DaysTableNameHandler extends BaseTableNameHandler {

    @Override
    protected String getDynamicTableName(String sql, String tableName) {
        String dateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        return StrUtil.format("{}_{}", tableName, dateString);
    }
}
